package com.ymatou.iapi.synctrade.testcase;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Random;

import org.apache.http.client.ClientProtocolException;
import org.joda.time.DateTime;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.google.common.collect.Lists;
import com.ymatou.iapi.optrade.parameter.enums.AuthenticateFeeTypeEnum;
import com.ymatou.iapi.optrade.parameter.enums.AuthenticateFreightTypeEnum;
import com.ymatou.iapi.optrade.parameter.enums.CancelOrderTypeEnum;
import com.ymatou.iapi.optrade.parameter.enums.LogisticsTypeEnum;
import com.ymatou.iapi.optrade.parameter.req.ApplyRefundReq;
import com.ymatou.iapi.optrade.parameter.req.ChangeLogisticsTypeReq;
import com.ymatou.iapi.optrade.parameter.req.ChangeRefundBillReq;
import com.ymatou.iapi.optrade.parameter.req.CustomsClearanceUnfreezeOrderReq;
import com.ymatou.iapi.optrade.parameter.req.DelayReceiveReq;
import com.ymatou.iapi.optrade.parameter.req.PlaceOrderReq;
import com.ymatou.iapi.optrade.parameter.req.RollbackToWaitDeliveryReq;
import com.ymatou.iapi.optrade.parameter.vo.OrderGroupVo;
import com.ymatou.iapi.optrade.parameter.vo.OrderItemVo;
import com.ymatou.iapi.optrade.parameter.vo.OrderVo;
import com.ymatou.iapi.optrade.parameter.vo.SalesRefundInfoVo;
import com.ymatou.iapi.optrade.parameter.vo.UbuyUserVo;
import com.ymatou.iapi.optrade.resp.Order;
import com.ymatou.iapi.optrade.resp.TradingServiceResp;
import com.ymatou.iapi.optrade.service.BargainGroupService;
import com.ymatou.iapi.optrade.service.ChangeLogisticsTypeCall;
import com.ymatou.iapi.optrade.service.ChangeSalesRefundInfoCall;
import com.ymatou.iapi.optrade.service.CustomsClearanceCall;
import com.ymatou.iapi.optrade.service.DelayReceiveCall;
import com.ymatou.iapi.optrade.service.PrepaidCardService;
import com.ymatou.iapi.optrade.service.RefundService;
import com.ymatou.iapi.optrade.service.RollbackToWaitDeliveryCall;
import com.ymatou.iapi.optrade.testcase.Ts_OrderPay;
import com.ymatou.iapi.synctrade.parameter.TradingSyncCmdEnum;
import com.ymatou.iapi.synctrade.service.TradingSyncService;
import com.ymt.base.YmatouEasyCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.P2;
import com.ymttest.business.service.AccountCallServiceV2;
import com.ymttest.business.service.AnlihuiCallService;
import com.ymttest.business.service.HunterCallService;
import com.ymttest.business.service.OrderCallService;
import com.ymttest.business.service.PayGateWayCallService;
import com.ymttest.business.service.YMTTrading.TradingCallService;
import com.ymttest.business.service.YMTTrading.TradingPlaceAnliOrderCallService;
import com.ymttest.business.service.YMTTrading.TradingPlaceAuthenticateCallService;
import com.ymttest.business.service.YMTTrading.TradingPlaceEngageOrderCallService;
import com.ymttest.business.service.YMTTrading.TradingPlaceHunterOrderCallService;
import com.ymttest.business.service.YMTTrading.TradingPlaceOrderCallService;
import com.ymttest.business.service.YMTTrading.TradingProductVo;
import com.ymttest.database.sharding.db.sharding.model.AutoReceiveOptPo;
import com.ymttest.database.sharding.db.sharding.model.OrderPo;
import com.ymttest.database.sharding.db.sqlwapper.OrderShardingWapper;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.YMTDateUtil;

/**
 * 同步指令接口 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_TradingSync {

	private static Integer userId = 20238699;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("同步指令接口");
	}

	@Before
	public void caseUp() {
		String accountid1;
		try {
			accountid1 = AccountCallServiceV2.getAccountId(userId);
			AccountCallServiceV2.resetAccount(accountid1, new BigDecimal(
					9000000), new BigDecimal(0));
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult("api/syncByCommand");
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_001() {
		Logger.start(true, "交易下单,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrder = TradingPlaceOrderCallService
					.placeOrderWithThreeProcutInTwoOrder(false,
							BigDecimal.ZERO, userId,
							LogisticsTypeEnum.OVERSEAS_DELIVERY);

			long userId = placeOrder.getUserId();

			long sellerId = placeOrder.getOrderList().get(0).getSellerId();

			long orderId = placeOrder.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_002() {
		Logger.start(true, "订单支付,使用买手优惠券，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrder = TradingPlaceOrderCallService
					.placeOrderWithThreeProcutInTwoOrder(true, BigDecimal.ZERO,
							userId, LogisticsTypeEnum.OVERSEAS_DELIVERY);

			long userId = placeOrder.getUserId();
			long sellerId = placeOrder.getOrderList().get(0).getSellerId();

			long tradingId = placeOrder.getTradingId();

			long orderId = placeOrder.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");
			// 支付订单
			TradingCallService.payOrder(userId, placeOrder.getPayableAmount(),
					tradingId);

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_003() {
		Logger.start(true, "订单付款之前取消订单,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			TradingServiceResp placeOrder = TradingPlaceOrderCallService
					.placeOrderWithThreeProcutInTwoOrder(false,
							BigDecimal.ZERO, userId,
							LogisticsTypeEnum.OVERSEAS_DELIVERY);
			long userId = placeOrder.getUserId();
			long sellerId = placeOrder.getOrderList().get(0).getSellerId();

			long orderId = placeOrder.getOrderList().get(0).getOrderId();
			Logger.comment("前置数据准备结束");

			// 取消订单
			TradingCallService.cancelOrder(orderId,
					CancelOrderTypeEnum.BUYER_CANCEL_ORDER, userId);

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_004() {
		Logger.start(true, "订单付款之后取消订单,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			TradingServiceResp placeOrder = TradingPlaceOrderCallService
					.placeOrderWithThreeProcutInTwoOrder(false,
							BigDecimal.ZERO, userId,
							LogisticsTypeEnum.OVERSEAS_DELIVERY);
			long userId = placeOrder.getUserId();
			long sellerId = placeOrder.getOrderList().get(0).getSellerId();

			long tradingId = placeOrder.getTradingId();
			long orderId = placeOrder.getOrderList().get(0).getOrderId();
			Logger.comment("前置数据准备结束");

			// 支付订单
			TradingCallService.payOrder(userId, placeOrder.getPayableAmount(),
					tradingId);

			// 取消订单
			TradingCallService.cancelOrder(orderId,
					CancelOrderTypeEnum.BUYER_CANCEL_ORDER, userId);

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_005() {
		Logger.start(true, "修改收货人地址,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			TradingServiceResp placeOrder = TradingCallService.payOrder();

			long userId = placeOrder.getUserId();
			long sellerId = placeOrder.getOrderList().get(0).getSellerId();

			long orderId = placeOrder.getOrderList().get(0).getOrderId();
			Logger.comment("前置数据准备结束");

			// 修改地址
			YmatouEasyCall YmatouEasyCall = new YmatouEasyCall("", "POST",
					"JSON");
			String orderJson = "{\"OrderId\":"
					+ orderId
					+ ",\"UserId\":"
					+ userId
					+ ",\"Address\":\"南京路步行街\",\"PostCode\":\"986574\",\"ReceievePerson\":\"洋码头\",\"Phone\":\"13200000005\",\"Telephone\":\"021-51025140\",\"QQ\":\"100001\",\"Email\":\"Hj02QUQuEXmk@sohu.com\",\"UserType\":\"Normal\",\"ChangeTime\":\"2016-12-26 10:57:26\"}";
			YmatouEasyCall
					.setUrl("http://optrade.iapi.ymatou.com/api/Buyer/ChangeOrderAddress");
			YmatouEasyCall.setData(orderJson);
			YmatouEasyCall.callService();

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_006() {
		Logger.start(true, "删除订单,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			TradingServiceResp placeOrder = TradingCallService.payOrder();
			long userId = placeOrder.getUserId();
			long sellerId = placeOrder.getOrderList().get(0).getSellerId();

			long orderId = placeOrder.getOrderList().get(0).getOrderId();
			Logger.comment("前置数据准备结束");

			// 删除订单
			YmatouEasyCall YmatouEasyCall = new YmatouEasyCall("", "POST",
					"JSON");
			String orderJson = "{\"orderId\":" + orderId
					+ ",\"isDelete\":true,\"userId\":" + userId + "}";
			YmatouEasyCall
					.setUrl("http://optrade.iapi.ymatou.com/api/Buyer/markOrderDeleted");
			YmatouEasyCall.setData(orderJson);
			YmatouEasyCall.callService();

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_007() {
		Logger.start(true, "订单调价,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			TradingServiceResp placeOrder = TradingPlaceOrderCallService
					.placeOrderWithThreeProcutInTwoOrder(false,
							BigDecimal.ZERO, userId,
							LogisticsTypeEnum.OVERSEAS_DELIVERY);

			long orderId = placeOrder.getOrderList().get(0).getOrderId();
			long sellerId = placeOrder.getOrderList().get(0).getSellerId();
			long userId = placeOrder.getUserId();

			Logger.comment("前置数据准备结束");

			// 调整订单折扣
			YmatouEasyCall YmatouEasyCall = new YmatouEasyCall("", "POST",
					"JSON");
			String orderJson = "{\"OrderId\":" + orderId + ",\"SellerId\":"
					+ sellerId
					+ ",\"Discount\":4,\"Freight\":5,\"DiscountTime\":\""
					+ YMTDateUtil.getSysTime() + "\"}";
			YmatouEasyCall
					.setUrl("http://optrade.iapi.ymatou.com/api/Seller/ChangeOrderDiscount");
			YmatouEasyCall.setData(orderJson);
			YmatouEasyCall.callService();

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_008() {
		Logger.start(true, "商家接单,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			TradingServiceResp placeOrder = TradingCallService.orderAccept();
			long userId = placeOrder.getUserId();
			long sellerId = placeOrder.getOrderList().get(0).getSellerId();

			long orderId = placeOrder.getOrderList().get(0).getOrderId();
			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_009() {
		Logger.start(true, "商家发货,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			TradingServiceResp placeOrderResp = TradingPlaceOrderCallService
					.placeOrderWithLogisticsType(LogisticsTypeEnum.OVERSEAS_DELIVERY);

			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			long userId = placeOrderResp.getUserId();

			long tradingId = placeOrderResp.getTradingId();

			BigDecimal useAccountAmount = placeOrderResp.getPayableAmount();

			TradingCallService.payOrder(userId, useAccountAmount, tradingId);

			TradingCallService.sellerAcceptOrder(sellerId, orderId);
			TradingSyncService.getSyncResult(orderId);

			Logger.comment("前置数据准备结束");

			TradingCallService.delivery(sellerId, orderId,
					LogisticsTypeEnum.OVERSEAS_DELIVERY, 1);

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_010() {
		Logger.start(true, "贝海物流清关,验证同步Mongo,ES数据");
		try {
			TradingServiceResp placeOrderResp = TradingCallService
					.orderDelivery();

			Long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			long userId = placeOrderResp.getUserId();

			String billNo = String.format("YD%s",
					TestDataManager.getRandomNum(10));

			// 码头保存物流单号
			TradingCallService.saveDeliverSummary(orderId, sellerId, billNo);

			CustomsClearanceUnfreezeOrderReq customsClearanceUnfreezeOrderReq = new CustomsClearanceUnfreezeOrderReq();
			CustomsClearanceCall customsClearanceCall = new CustomsClearanceCall();

			customsClearanceUnfreezeOrderReq.setLogisticsNos(Arrays
					.asList(billNo));

			customsClearanceCall.setData(false,
					customsClearanceUnfreezeOrderReq);

			customsClearanceCall.callService();

			TradingSyncService.syncOrderCmd(userId, orderId,
					TradingSyncCmdEnum.LOGISTICS_CODE);

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_011() {
		Logger.start(true, "国内段发货,验证同步Mongo,ES数据");
		try {
			Logger.comment("前置数据准备");

			// 创建一个拼邮的订单
			TradingServiceResp placeOrderResp = TradingPlaceOrderCallService
					.placeOrderWithLogisticsType(LogisticsTypeEnum.OVERSEAS_DELIVERY);

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			long userId = placeOrderResp.getUserId();
			// 支付订单
			TradingCallService.payOrder(userId,
					placeOrderResp.getPayableAmount(),
					placeOrderResp.getTradingId());
			// 接单
			TradingCallService.sellerAcceptOrder(sellerId, orderId);
			TradingSyncService.getSyncResult(orderId);
			// 拼邮国际段发货
			TradingCallService.delivery(sellerId, orderId,
					LogisticsTypeEnum.OVERSEAS_DELIVERY, 1);
			TradingSyncService.getSyncResult(orderId);
			// 拼邮国内段发货
			TradingCallService.delivery(sellerId, orderId,
					LogisticsTypeEnum.OVERSEAS_DELIVERY, 3);

			Logger.comment("前置数据准备结束");

			TradingSyncService.syncOrderCmd(userId, orderId,
					TradingSyncCmdEnum.LOGISTICS_CODE);

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_012() {
		Logger.start(true, "发货回退到待发货状态,验证同步Mongo,ES数据");
		try {

			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrderResp = TradingPlaceOrderCallService
					.placeOrderWithLogisticsType(LogisticsTypeEnum.OVERSEAS_DELIVERY);

			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			long userId = placeOrderResp.getUserId();

			long tradingId = placeOrderResp.getTradingId();

			BigDecimal useAccountAmount = placeOrderResp.getPayableAmount();

			TradingCallService.payOrder(userId, useAccountAmount, tradingId);

			TradingCallService.sellerAcceptOrder(sellerId, orderId);

			TradingCallService.delivery(sellerId, orderId,
					LogisticsTypeEnum.OVERSEAS_DELIVERY, 1);

			Logger.comment("前置数据准备结束");

			Thread.sleep(5000);

			String operateUser = "sys";
			String reason = "autotest rollback";

			RollbackToWaitDeliveryReq rollbackToWaitDeliveryReq = new RollbackToWaitDeliveryReq();
			RollbackToWaitDeliveryCall rollbacktowaitdeliveryCall = new RollbackToWaitDeliveryCall();

			rollbackToWaitDeliveryReq.setOrderId(orderId);
			rollbackToWaitDeliveryReq.setOperateUser(operateUser);
			rollbackToWaitDeliveryReq.setReason(reason);
			rollbacktowaitdeliveryCall
					.setData(false, rollbackToWaitDeliveryReq);

			rollbacktowaitdeliveryCall.callService();

			TradingSyncService.syncOrderCmd(userId, orderId,
					TradingSyncCmdEnum.LOGISTICS_CODE);

			Thread.sleep(5000);

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_013() {
		Logger.start(true, "发货回退到待发货状态后,再发货,验证同步Mongo,ES数据");
		try {

			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrderResp = TradingPlaceOrderCallService
					.placeOrderWithLogisticsType(LogisticsTypeEnum.OVERSEAS_DELIVERY);

			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			long userId = placeOrderResp.getUserId();

			long tradingId = placeOrderResp.getTradingId();

			BigDecimal useAccountAmount = placeOrderResp.getPayableAmount();

			TradingCallService.payOrder(userId, useAccountAmount, tradingId);

			TradingCallService.sellerAcceptOrder(sellerId, orderId);

			Thread.sleep(3000);

			TradingCallService.delivery(sellerId, orderId,
					LogisticsTypeEnum.OVERSEAS_DELIVERY, 1);

			Logger.comment("前置数据准备结束");

			Thread.sleep(5000);

			String operateUser = "sys";
			String reason = "autotest rollback";

			RollbackToWaitDeliveryReq rollbackToWaitDeliveryReq = new RollbackToWaitDeliveryReq();
			RollbackToWaitDeliveryCall rollbacktowaitdeliveryCall = new RollbackToWaitDeliveryCall();

			rollbackToWaitDeliveryReq.setOrderId(orderId);
			rollbackToWaitDeliveryReq.setOperateUser(operateUser);
			rollbackToWaitDeliveryReq.setReason(reason);
			rollbacktowaitdeliveryCall
					.setData(false, rollbackToWaitDeliveryReq);
			rollbacktowaitdeliveryCall.callService();

			TradingSyncService.syncOrderCmd(userId, orderId,
					TradingSyncCmdEnum.LOGISTICS_CODE);

			Thread.sleep(3000);

			TradingSyncService.syncOrderCmd(userId, orderId,
					TradingSyncCmdEnum.LOGISTICS_CODE);

			TradingCallService.delivery(sellerId, orderId,
					LogisticsTypeEnum.OVERSEAS_DELIVERY, 1);

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_014() {
		Logger.start(true, "用户延迟收货时间,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			TradingServiceResp placeOrderResp = TradingPlaceOrderCallService
					.placeOrderWithLogisticsType(LogisticsTypeEnum.OVERSEAS_DELIVERY);

			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			long userId = placeOrderResp.getUserId();

			long tradingId = placeOrderResp.getTradingId();

			BigDecimal useAccountAmount = placeOrderResp.getPayableAmount();

			TradingCallService.payOrder(userId, useAccountAmount, tradingId);

			TradingCallService.sellerAcceptOrder(sellerId, orderId);

			TradingCallService.delivery(sellerId, orderId,
					LogisticsTypeEnum.OVERSEAS_DELIVERY, 1);

			// 自动确认收货时间操作表（auto_receive_opt）
			AutoReceiveOptPo record = new AutoReceiveOptPo();
			record.setOrderId(orderId);
			record.setExpectReceiveTime(DateTime.now().plusDays(-1).toDate());
			record.setFreeze(false);

			// 修改预期自动确认收货
			new OrderShardingWapper().autoReceiveOptMapper
					.updateByPrimaryKeySelective(record);

			Logger.comment("前置数据准备结束");

			int delayDay = new Random().nextInt(10) + 1;

			DelayReceiveReq delayReceiveReq = new DelayReceiveReq();
			DelayReceiveCall delayReceiveCall = new DelayReceiveCall();

			delayReceiveReq.setDelayDay(delayDay);
			delayReceiveReq.setOrderId(orderId);
			delayReceiveReq.setOperateUserId(userId);

			delayReceiveReq.setOperateUserType(0);
			// 发送请求
			delayReceiveCall.setData(false, delayReceiveReq);
			delayReceiveCall.callService();

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_015() {
		Logger.start(true, "确认收货,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 创建一个拼邮的订单
			TradingServiceResp placeOrderResp = TradingPlaceOrderCallService
					.placeOrderWithLogisticsType(LogisticsTypeEnum.OVERSEAS_DELIVERY);

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			long userId = placeOrderResp.getUserId();

			// 支付订单
			TradingCallService.payOrder(userId,
					placeOrderResp.getPayableAmount(),
					placeOrderResp.getTradingId());
			// 接单
			TradingCallService.sellerAcceptOrder(sellerId, orderId);
			TradingSyncService.getSyncResult(orderId);
			// 拼邮国际段发货
			TradingCallService.delivery(sellerId, orderId,
					LogisticsTypeEnum.OVERSEAS_DELIVERY, 1);
			TradingSyncService.getSyncResult(orderId);
			// 拼邮国内段发货
			TradingCallService.delivery(sellerId, orderId,
					LogisticsTypeEnum.OVERSEAS_DELIVERY, 3);
			Logger.comment("前置数据准备结束");

			TradingCallService.confirmReceive(userId, orderId);

			TradingSyncService.getSyncResult(orderId);

			Thread.sleep(3000);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_016() {
		Logger.start(true, "修改身份证号码,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			TradingServiceResp placeOrder = TradingPlaceOrderCallService
					.placeOrderWithLogisticsType(LogisticsTypeEnum.OVERSEAS_DELIVERY);

			long userId = placeOrder.getUserId();
			long sellerId = placeOrder.getOrderList().get(0).getSellerId();

			long orderId = placeOrder.getOrderList().get(0).getOrderId();
			Logger.comment("前置数据准备结束");

			// 通知订单身份证信息
			YmatouEasyCall YmatouEasyCall = new YmatouEasyCall("", "POST",
					"JSON");

			String orderJson = "{\"orderId\":" + orderId
					+ ",\"businessType\":15}";
			YmatouEasyCall
					.setUrl("http://optrade.iapi.ymatou.com/api/Common/syncOrderIdCard");

			YmatouEasyCall.setData(orderJson);
			YmatouEasyCall.callService();

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_017() {
		Logger.start(true, "支付回调标示新老客,验证同步Mongo,ES数据");
		try {
			// 创建订单
			TradingServiceResp placeOrderResp = TradingCallService.payOrder();

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			long userId = placeOrderResp.getUserId();
			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_018() {
		Logger.start(true, "风控,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			TradingServiceResp placeOrder = TradingPlaceOrderCallService
					.placeOrderWithLogisticsType(LogisticsTypeEnum.OVERSEAS_DELIVERY);
			long userId = placeOrder.getUserId();
			long sellerId = placeOrder.getOrderList().get(0).getSellerId();

			long tradingId = placeOrder.getTradingId();
			long orderId = placeOrder.getOrderList().get(0).getOrderId();
			Logger.comment("前置数据准备结束");

			// 支付订单
			TradingCallService.payOrder(userId, placeOrder.getPayableAmount(),
					tradingId);

			// 订单支付风控系统通知
			TradingSyncService.riskControlNotify(orderId, "Rejected");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_019() {
		Logger.start(true, "订单备注,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			TradingServiceResp placeOrder = TradingPlaceOrderCallService
					.placeOrderWithLogisticsType(LogisticsTypeEnum.OVERSEAS_DELIVERY);
			long userId = placeOrder.getUserId();
			long sellerId = placeOrder.getOrderList().get(0).getSellerId();

			long orderId = placeOrder.getOrderList().get(0).getOrderId();
			Logger.comment("前置数据准备结束");

			// 修改订单note
			YmatouEasyCall YmatouEasyCall = new YmatouEasyCall("", "POST",
					"JSON");

			String orderJson = "{\"OrderId\":"
					+ orderId
					+ ",\"UserId\":"
					+ userId
					+ ",\"RemarkContent\":\"修改订单备注01\",\"RemarkLevel\":1,\"RemarkTime\":\"2016-12-26 15:53:01\"}";
			YmatouEasyCall
					.setUrl("http://optrade.iapi.ymatou.com/api/Seller/ChangeOrderNote");
			YmatouEasyCall.setData(orderJson);
			YmatouEasyCall.callService();

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_020() {
		Logger.start(true, "申请退款,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			TradingServiceResp placeOrder = TradingCallService
					.orderApplyRefund();

			long userId = placeOrder.getUserId();
			long sellerId = placeOrder.getOrderList().get(0).getSellerId();

			long orderId = placeOrder.getOrderList().get(0).getOrderId();
			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_0201() {
		Logger.start(true, "申请多次退款,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			TradingServiceResp placeOrder = TradingCallService.orderAccept();

			long userId = placeOrder.getUserId();
			long sellerId = placeOrder.getOrderList().get(0).getSellerId();

			long orderId = placeOrder.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_021() {
		Logger.start(true, "修改退款申请单,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrderResp = TradingPlaceOrderCallService
					.placeOrderWithThreeProcutInTwoOrder(true, BigDecimal.ZERO,
							userId, LogisticsTypeEnum.OVERSEAS_DELIVERY);

			Order order = placeOrderResp.getOrderList().get(0);

			Long userId = placeOrderResp.getUserId();
			Long orderId = order.getOrderId();

			long sellerId = order.getSellerId();

			BigDecimal orderFreight = order.getOrderFreight();

			BigDecimal proFreight = order.getOrderDetailPoList().get(0)
					.getFreight();

			// 支付
			TradingCallService.payOrder(placeOrderResp.getUserId(),
					placeOrderResp.getPayableAmount(),
					placeOrderResp.getTradingId());
			// 接单
			TradingCallService.sellerAcceptOrder(order.getSellerId(), orderId);

			// 申请改订单下第一个商品退款
			ApplyRefundReq applyRefundReq = RefundService
					.buildStandApplyRefundReq(order);

			SalesRefundInfoVo oldRefundInfoVo = applyRefundReq
					.getSalesRefundInfoList().get(0);

			applyRefundReq.setSalesRefundInfoList(Arrays
					.asList(oldRefundInfoVo));

			RefundService.applyRefundCall(applyRefundReq);

			ChangeRefundBillReq changeRefundBillReq = new ChangeRefundBillReq();

			ChangeSalesRefundInfoCall changeSalesRefundInfoCall = new ChangeSalesRefundInfoCall();

			changeRefundBillReq.setOrderId(orderId);
			changeRefundBillReq.setRefundBillNo(oldRefundInfoVo
					.getRefundBillNo());

			changeRefundBillReq.setRefundAmount(oldRefundInfoVo
					.getRefundAmount().add(orderFreight.subtract(proFreight)));

			changeRefundBillReq.setRefundProductNum(oldRefundInfoVo
					.getRefundProductNum());

			changeRefundBillReq.setRefundType(1);
			changeRefundBillReq.setReason("123456789");

			changeSalesRefundInfoCall.setData(false, changeRefundBillReq);
			changeSalesRefundInfoCall.callService();

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_022() {
		Logger.start(true, "拒绝退款,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrderResp = TradingPlaceOrderCallService
					.placeOrderWithThreeProcutInTwoOrder(true, BigDecimal.ZERO,
							userId, LogisticsTypeEnum.OVERSEAS_DELIVERY);

			Order order = placeOrderResp.getOrderList().get(0);

			Long userId = placeOrderResp.getUserId();
			Long orderId = order.getOrderId();

			long sellerId = order.getSellerId();

			// 支付
			TradingCallService.payOrder(placeOrderResp.getUserId(),
					placeOrderResp.getPayableAmount(),
					placeOrderResp.getTradingId());
			// 接单
			TradingCallService.sellerAcceptOrder(order.getSellerId(), orderId);

			// 拒绝退款
			RefundService.rejectRefundBill(order);

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_023() {
		Logger.start(true, "退款成功,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrderResp = TradingPlaceOrderCallService
					.placeOrderWithThreeProcutInTwoOrder(true, BigDecimal.ZERO,
							userId, LogisticsTypeEnum.OVERSEAS_DELIVERY);

			Order order = placeOrderResp.getOrderList().get(0);

			Long userId = placeOrderResp.getUserId();
			Long orderId = order.getOrderId();

			long sellerId = order.getSellerId();

			// 支付
			TradingCallService.payOrder(placeOrderResp.getUserId(),
					placeOrderResp.getPayableAmount(),
					placeOrderResp.getTradingId());
			// 接单
			TradingCallService.sellerAcceptOrder(order.getSellerId(), orderId);

			// 退款
			RefundService.approveRefund(order);

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_024() {
		Logger.start(true, "全都退款后取消订单,验证数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrderResp = TradingPlaceOrderCallService
					.placeOrderWithThreeProcutInTwoOrder(true, BigDecimal.ZERO,
							userId, LogisticsTypeEnum.OVERSEAS_DELIVERY);

			Order order = placeOrderResp.getOrderList().get(0);

			Long userId = placeOrderResp.getUserId();
			Long orderId = order.getOrderId();

			long sellerId = order.getSellerId();

			// 支付
			TradingCallService.payOrder(placeOrderResp.getUserId(),
					placeOrderResp.getPayableAmount(),
					placeOrderResp.getTradingId());
			// 接单
			TradingCallService.sellerAcceptOrder(order.getSellerId(), orderId);

			// 退款
			RefundService.applyRefund(order);

			RefundService.approveRefund(order);

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_025() {
		Logger.start(true, "修改物流类型,验证同步Mongo,ES数据");
		try {

			TradingServiceResp placeOrderResp = TradingCallService.payOrder();

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			ChangeLogisticsTypeReq codnbean = new ChangeLogisticsTypeReq();
			ChangeLogisticsTypeCall codncall = new ChangeLogisticsTypeCall();

			codnbean.setLogisticsType(LogisticsTypeEnum.OVERSEAS_DELIVERY
					.getCode());

			codnbean.setOrderId(orderId);
			codnbean.setSellerId(sellerId);
			codnbean.setLogisticsAging(15);
			codnbean.setOfficialLogistics(true);

			// 发送请求
			codncall.setData(false, codnbean);
			codncall.callService();

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_026() {
		Logger.start(true, "修改物流单号,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrderResp = TradingPlaceOrderCallService
					.placeOrderWithLogisticsType(LogisticsTypeEnum.OVERSEAS_DELIVERY);

			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			long userId = placeOrderResp.getUserId();

			long tradingId = placeOrderResp.getTradingId();

			BigDecimal useAccountAmount = placeOrderResp.getPayableAmount();

			TradingCallService.payOrder(userId, useAccountAmount, tradingId);

			TradingCallService.sellerAcceptOrder(sellerId, orderId);

			String oldBillNo = TradingCallService.delivery(sellerId, orderId,
					LogisticsTypeEnum.OVERSEAS_DELIVERY, 1);
			Logger.comment("前置数据准备结束");

			// 商家发货

			String newBillCode = TestDataManager.randomStr(10);

			TradingSyncService.modifyDeliverBillCode(orderId, sellerId,
					newBillCode, oldBillNo, "Y066");

			TradingSyncService.syncOrderCmd(userId, orderId,
					TradingSyncCmdEnum.LOGISTICS_CODE);

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_027() {
		Logger.start(true, "确认收货之后退款成功,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrder = TradingCallService
					.orderConfirmReceive();

			Order order = placeOrder.getOrderList().get(0);
			long userId = placeOrder.getUserId();
			long sellerId = placeOrder.getOrderList().get(0).getSellerId();

			long orderId = placeOrder.getOrderList().get(0).getOrderId();

			TradingSyncService.getSyncResult(orderId);

			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			// 申请退款
			RefundService.approveRefund(order);
			TradingSyncService.getSyncResult(orderId);

			Thread.sleep(3000);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_031() {
		Logger.start(true, "创建砍价团参团订单,砍价团通知组团成功,ORDER_BIZ指令调用成功,验证数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 砍价团id
			String bizId = TestDataManager.getRandomNum(9);

			TradingServiceResp placeOrderResp = BargainGroupService
					.openGroup(bizId);

			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();

			// 参团
			TradingServiceResp placeOrder2 = BargainGroupService
					.joinGroup(bizId);

			long orderId = placeOrder2.getOrderList().get(0).getOrderId();
			long userId = placeOrder2.getUserId();

			Logger.comment("前置数据准备结束");

			BargainGroupService.notifyOrderBizStatus(bizId, orderId, 2, 3);

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_032() {
		Logger.start(true, "创建砍价团参团订单,砍价团通知组团失败,ORDER_BIZ指令调用成功,验证数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 砍价团id
			String bizId = TestDataManager.getRandomNum(9);

			TradingServiceResp placeOrderResp = BargainGroupService
					.openGroup(bizId);

			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();

			// 参团
			TradingServiceResp placeOrder2 = BargainGroupService
					.joinGroup(bizId);

			long orderId = placeOrder2.getOrderList().get(0).getOrderId();
			long userId = placeOrder2.getUserId();

			Logger.comment("前置数据准备结束");

			BargainGroupService.notifyOrderBizStatus(bizId, orderId, 2, -3);

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_036() {
		Logger.start(true, "第三方支付,PAY指令调用成功,验证数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			TradingServiceResp placeOrder = TradingPlaceOrderCallService
					.placeOrderWithThreeProcutInTwoOrder(true, BigDecimal.ZERO,
							userId, LogisticsTypeEnum.OVERSEAS_DELIVERY);

			Long userId = placeOrder.getUserId();
			long sellerId = placeOrder.getOrderList().get(0).getSellerId();

			long tradingId = placeOrder.getTradingId();

			long orderId = placeOrder.getOrderList().get(0).getOrderId();

			BigDecimal totalPrice = placeOrder.getPayableAmount();

			Logger.comment("前置数据准备结束");

			// 13 为 app国际支付宝，15 微信
			String payType = "13";

			Long thirdTradingId = TradingCallService.payOrder(userId,
					BigDecimal.ZERO, tradingId, payType);

			// 支付网关支付回调
			PayGateWayCallService.notifyCall(payType,
					thirdTradingId.toString(),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue());

			Thread.sleep(5000);

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_038() {
		Logger.start(true, "含有组合商品的订单下单成功,验证数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrder = Ts_OrderPay.placeOrder();
			;

			long userId = placeOrder.getUserId();
			long sellerId = placeOrder.getOrderList().get(0).getSellerId();
			long orderId = placeOrder.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");
			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_039() {
		Logger.start(true, "含有组合商品的订单下单,使用招行支付,验证数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrder = Ts_OrderPay.placeOrder();

			Long userId = placeOrder.getUserId();
			long sellerId = placeOrder.getOrderList().get(0).getSellerId();
			long orderId = placeOrder.getOrderList().get(0).getOrderId();
			long tradingId = placeOrder.getTradingId();
			BigDecimal totalPrice = placeOrder.getPayableAmount();

			Logger.comment("前置数据准备结束");

			// 获取用户需要支付的金额
			String payType = "50";
			Long thirdTradingId = TradingCallService.payOrder(userId,
					BigDecimal.ZERO, tradingId, payType);

			// 支付网关支付回调交易
			PayGateWayCallService.cmbNotifyCall(thirdTradingId.toString(),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.TEN.toString());

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_040() {
		Logger.start(true, "含有组合商品的订单后,调整运费，折扣,验证数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrder = Ts_OrderPay.placeOrder();

			long userId = placeOrder.getUserId();
			long sellerId = placeOrder.getOrderList().get(0).getSellerId();
			long orderId = placeOrder.getOrderList().get(0).getOrderId();

			// 调整订单折扣
			YmatouEasyCall YmatouEasyCall = new YmatouEasyCall("", "POST",
					"JSON");
			String orderJson = "{\"OrderId\":" + orderId + ",\"SellerId\":"
					+ sellerId
					+ ",\"Discount\":28,\"Freight\":35,\"DiscountTime\":\""
					+ YMTDateUtil.getSysTime() + "\"}";
			YmatouEasyCall
					.setUrl("http://optrade.iapi.ymatou.com/api/Seller/ChangeOrderDiscount");
			YmatouEasyCall.setData(orderJson);
			YmatouEasyCall.callService();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_041() {
		Logger.start(true, "使用了预付卡订单,取消后,验证数据");
		try {
			Logger.comment("准备前置数据");

			TradingServiceResp placeOrderResp = PrepaidCardService
					.placeOrder2(false);

			List<Order> orders = placeOrderResp.getOrderList();

			Long userId = placeOrderResp.getUserId();
			long tradingId = placeOrderResp.getTradingId();

			long orderId = orders.get(0).getOrderId();

			long sellerId = orders.get(0).getSellerId();

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			// 用余额支付
			BigDecimal useAccountAmount = new BigDecimal(10);

			// 买家付款
			Long thirdTradingId = TradingCallService.payOrder(userId,
					useAccountAmount, tradingId, "13");

			// 支付网关支付回调交易
			PayGateWayCallService.notifyCall("13",
					String.valueOf(thirdTradingId),
					totalPrice.subtract(useAccountAmount).toString(),
					userId.intValue());

			Thread.sleep(5000);

			TradingCallService.cancelOrder(orderId,
					CancelOrderTypeEnum.BUYER_CANCEL_ORDER, userId);

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			Thread.sleep(5000);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_042() {
		Logger.start(true, "使用了预付卡订单,退款后,验证数据");
		try {
			Logger.comment("准备前置数据");
			TradingServiceResp placeOrderResp = PrepaidCardService
					.placeOrder2(true);

			Order order = placeOrderResp.getOrderList().get(0);
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			Long userId = placeOrderResp.getUserId();

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			// 用余额支付金额
			BigDecimal useAccountAmount = new BigDecimal(47);
			// 支付订单 余额+支付宝组合支付
			// 13 为 app国际支付宝，15 微信
			String payType = "13";

			Long thirdTradingId = TradingCallService.payOrder(
					placeOrderResp.getUserId(), useAccountAmount,
					placeOrderResp.getTradingId(), payType);

			// 支付网关支付回调交易
			PayGateWayCallService.notifyCall(payType,
					String.valueOf(thirdTradingId),
					totalPrice.subtract(useAccountAmount).toString(),
					userId.intValue());

			// 等待支付网关异步处理
			Thread.sleep(5000);

			// 卖家接单
			TradingCallService.sellerAcceptOrder(sellerId, orderId);
			// 申请退款
			RefundService.approveRefund(order);

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_043() {
		Logger.start(true, "预售订单,验证同步Mongo,ES数据");
		try {
			
			Long sellerId = Long.valueOf(EnvSetup.getData("autotest_seller1"));
			String sellerName = String.valueOf(EnvSetup.getData("autotest_sellerName1"));

			PlaceOrderReq placeOrderReq = TradingCallService
					.buildStandPlaceOrderReq();
			
			OrderGroupVo orderGroupVo = TradingCallService.createOrderGroupVo(
					sellerId, sellerName);
			OrderVo orderVo = TradingCallService.createOrderVo();

			TradingProductVo productVo = TradingProductVo.createPro(sellerId,
					sellerName, 5);

			OrderItemVo orderItemVo = TradingCallService.createOrderItemVo(
					productVo.getProductId(), productVo.getCatalogId());
			
			orderItemVo.setPreSale(true);

			orderVo.setOrderItems(Arrays.asList(orderItemVo));

			orderGroupVo.setOrders(Arrays.asList(orderVo));

			placeOrderReq.setOrderGroups(Arrays.asList(orderGroupVo));

			TradingServiceResp placeOrderResp = TradingCallService
					.callPlaceOrderService(placeOrderReq);

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_044() {
		Logger.start(true, "下单含有平台优惠商品订单,验证同步Mongo,ES数据");
		try {

			PlaceOrderReq placeOrderReq = TradingCallService
					.buildStandPlaceOrderReq();

			Long sellerId = Long.valueOf(EnvSetup.getData("autotest_seller1"));
			String sellerName = String.valueOf(EnvSetup
					.getData("autotest_sellerName1"));

			// 一个商家组
			OrderGroupVo groupVo = TradingCallService.createOrderGroupVo(
					sellerId, sellerName);

			// 订单信息
			OrderVo orderVo = TradingCallService.createOrderVo();

			// 创建一个普通商品
			TradingProductVo product = TradingProductVo.createPro(sellerId,
					sellerName, 100);

			// 创建订单项
			OrderItemVo orderItemVo = TradingCallService.createOrderItemVo(product.getProductId(),
					product.getCatalogId());
			orderItemVo.setYmtPromotionAmount(BigDecimal.TEN);

			orderVo.setOrderItems(Lists.newArrayList(orderItemVo));
			// 添加订单
			groupVo.setOrders(Lists.newArrayList(orderVo));

			placeOrderReq.setOrderGroups(Lists.newArrayList(groupVo));

			TradingServiceResp placeOrderResp = TradingCallService
					.callPlaceOrderService(placeOrderReq);

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_045() {
		Logger.start(true, "下单含有app内平台立减优惠,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrder = TradingPlaceOrderCallService
					.placeOrderWithThreeProcutInTwoOrder(false, BigDecimal.TEN,
							userId, LogisticsTypeEnum.OVERSEAS_DELIVERY);

			long userId = placeOrder.getUserId();

			long sellerId = placeOrder.getOrderList().get(0).getSellerId();

			long orderId = placeOrder.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_046() {
		Logger.start(true, "订单支付含有app内平台立减优惠,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrder = TradingPlaceOrderCallService
					.placeOrderWithThreeProcutInTwoOrder(false, BigDecimal.TEN,
							userId, LogisticsTypeEnum.OVERSEAS_DELIVERY);

			long userId = placeOrder.getUserId();
			long sellerId = placeOrder.getOrderList().get(0).getSellerId();

			long tradingId = placeOrder.getTradingId();

			long orderId = placeOrder.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");
			// 支付订单
			TradingCallService.payOrder(userId, placeOrder.getPayableAmount(),
					tradingId, true, 1);

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_047() {
		Logger.start(true, "含有app内平台立减优惠订单付款之前取消订单,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			TradingServiceResp placeOrder = TradingPlaceOrderCallService
					.placeOrderWithThreeProcutInTwoOrder(false, BigDecimal.TEN,
							userId, LogisticsTypeEnum.OVERSEAS_DELIVERY);

			long userId = placeOrder.getUserId();
			long sellerId = placeOrder.getOrderList().get(0).getSellerId();

			long orderId = placeOrder.getOrderList().get(0).getOrderId();
			Logger.comment("前置数据准备结束");

			// 取消订单
			TradingCallService.cancelOrder(orderId,
					CancelOrderTypeEnum.BUYER_CANCEL_ORDER, userId);

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_TradingSync_048() {
		Logger.start(true, "分销大礼包订单下单成功,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			OrderShardingWapper orderShardingWapper = new OrderShardingWapper();
			List<OrderPo> orderList = orderShardingWapper
					.selectHunterGiftBagOrderbyUserId(Long.valueOf(EnvSetup
							.getData("BuyUserId")));

			if (orderList.size() > 0) {
				for (OrderPo po : orderList) {
					TradingCallService.cancelOrder(po.getOrderId(),
							CancelOrderTypeEnum.BUYER_CANCEL_ORDER,
							Long.valueOf(EnvSetup.getData("BuyUserId")));
				}
			}

			long hunterId = 1234;
			TradingServiceResp placeOrder = TradingPlaceHunterOrderCallService
					.placeHunterOrder(hunterId, 1);
			long userId = placeOrder.getUserId();
			long sellerId = placeOrder.getOrderList().get(0).getSellerId();

			long orderId = placeOrder.getOrderList().get(0).getOrderId();
			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId, hunterId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_TradingSync_049() {
		Logger.start(true, "分销普通商品订单下单成功,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			long hunterId = 4321;
			TradingServiceResp placeOrder = TradingPlaceHunterOrderCallService
					.placeHunterOrder(hunterId, 2);
			long userId = placeOrder.getUserId();
			long sellerId = placeOrder.getOrderList().get(0).getSellerId();

			long orderId = placeOrder.getOrderList().get(0).getOrderId();
			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId, hunterId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_TradingSync_050() {
		Logger.start(true, "分销大礼包订单下单并支付,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			long hunterId = 4321;
			TradingServiceResp placeOrder = TradingPlaceHunterOrderCallService
					.placeHunterOrder(hunterId, 1);
			Long userId = placeOrder.getUserId();
			long sellerId = placeOrder.getOrderList().get(0).getSellerId();
			long orderId = placeOrder.getOrderList().get(0).getOrderId();
			long tradingId = placeOrder.getTradingId();
			BigDecimal totalPrice = placeOrder.getPayableAmount();

			Long thirdTradingId = TradingCallService.payOrder(userId,
					BigDecimal.ZERO, tradingId, "13");

			PayGateWayCallService.notifyCall("13", thirdTradingId.toString(),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue());
			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId, hunterId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_TradingSync_051() {
		Logger.start(true, "分销普通商品订单下单并支付,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			long hunterId = 4321;
			TradingServiceResp placeOrder = TradingPlaceHunterOrderCallService
					.placeHunterOrder(hunterId, 2);
			Long userId = placeOrder.getUserId();
			long sellerId = placeOrder.getOrderList().get(0).getSellerId();
			long orderId = placeOrder.getOrderList().get(0).getOrderId();
			long tradingId = placeOrder.getTradingId();
			BigDecimal totalPrice = placeOrder.getPayableAmount();

			Long thirdTradingId = TradingCallService.payOrder(userId,
					BigDecimal.ZERO, tradingId, "13");

			PayGateWayCallService.notifyCall("13", thirdTradingId.toString(),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue());
			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			Thread.sleep(3000);
			TradingSyncService.verify(orderId, userId, sellerId, hunterId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_TradingSync_052() {
		Logger.start(true, "分销大礼包订单确认收货,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			OrderShardingWapper orderShardingWapper = new OrderShardingWapper();
			List<OrderPo> orderList = orderShardingWapper
					.selectHunterGiftBagOrderbyUserId(Long.valueOf(EnvSetup
							.getData("BuyUserId")));

			if (orderList.size() > 0) {
				for (OrderPo po : orderList) {
					TradingCallService.cancelOrder(po.getOrderId(),
							CancelOrderTypeEnum.BUYER_CANCEL_ORDER,
							Long.valueOf(EnvSetup.getData("BuyUserId")));
				}
			}

			long hunterId = 1022;
			TradingServiceResp placeOrder = TradingPlaceHunterOrderCallService
					.placeHunterOrder(hunterId, 1);
			Long userId = placeOrder.getUserId();
			long sellerId = placeOrder.getOrderList().get(0).getSellerId();
			long orderId = placeOrder.getOrderList().get(0).getOrderId();
			long tradingId = placeOrder.getTradingId();
			BigDecimal totalPrice = placeOrder.getPayableAmount();

			Long thirdTradingId = TradingCallService.payOrder(userId,
					BigDecimal.ZERO, tradingId, "13");

			PayGateWayCallService.notifyCall("13", thirdTradingId.toString(),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue());
			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(5000);

			// 拼邮国际段发货
			TradingCallService.delivery(sellerId, orderId,
					LogisticsTypeEnum.OVERSEAS_DELIVERY, 1);
			TradingSyncService.getSyncResult(orderId);
			// 拼邮国内段发货
			TradingCallService.delivery(sellerId, orderId,
					LogisticsTypeEnum.OVERSEAS_DELIVERY, 3);

			TradingCallService.confirmReceive(userId, orderId);

			Thread.sleep(5000);

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId, hunterId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_TradingSync_053() {
		Logger.start(true, "分销普通商品订单确认收货,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			long hunterId = 1022;
			TradingServiceResp placeOrder = TradingPlaceHunterOrderCallService
					.placeHunterOrder(hunterId, 2);
			Long userId = placeOrder.getUserId();
			long sellerId = placeOrder.getOrderList().get(0).getSellerId();
			long orderId = placeOrder.getOrderList().get(0).getOrderId();
			long tradingId = placeOrder.getTradingId();
			BigDecimal totalPrice = placeOrder.getPayableAmount();

			Long thirdTradingId = TradingCallService.payOrder(userId,
					BigDecimal.ZERO, tradingId, "13");

			PayGateWayCallService.notifyCall("13", thirdTradingId.toString(),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue());
			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(10000);

			// 拼邮国际段发货
			TradingCallService.delivery(sellerId, orderId,
					LogisticsTypeEnum.OVERSEAS_DELIVERY, 1);
			TradingSyncService.getSyncResult(orderId);
			// 拼邮国内段发货
			TradingCallService.delivery(sellerId, orderId,
					LogisticsTypeEnum.OVERSEAS_DELIVERY, 3);

			TradingCallService.confirmReceive(userId, orderId);
			Logger.comment("前置数据准备结束");

			Thread.sleep(10000);

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId, hunterId);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_TradingSync_054() {
		Logger.start(true, "分销系统触发形成永久绑定关系时，将该用户之前未付款订单，更新至最新关联关系");

		/**
		 * 
		 1、用户P之前有未付款的普通商品 2、用户P没有已支付的订单
		 */
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			int userId = new OrderCallService().createNewUser();

			long hunterId001 = HunterCallService.buildHunterRelation(2, 1, 0)
					.get(0);
			long hunterId002 = HunterCallService.buildHunterRelation(3, 1, 0)
					.get(0);

			TradingServiceResp placeOrder1 = TradingPlaceHunterOrderCallService
					.placeHunterOrder(hunterId001, userId, 2);
			long sellerId001 = placeOrder1.getOrderList().get(0).getSellerId();
			long orderId001 = placeOrder1.getOrderList().get(0).getOrderId();

			TradingServiceResp placeOrder2 = TradingPlaceHunterOrderCallService
					.placeHunterOrder(hunterId002, userId, 2);
			long sellerId002 = placeOrder2.getOrderList().get(0).getSellerId();
			long orderId002 = placeOrder2.getOrderList().get(0).getOrderId();

			long latestHunter = 1022;
			TradingServiceResp placeOrder3 = TradingPlaceHunterOrderCallService
					.placeHunterOrder(latestHunter, userId, 2);
			long sellerId = placeOrder3.getOrderList().get(0).getSellerId();
			long orderId = placeOrder3.getOrderList().get(0).getOrderId();
			long tradingId = placeOrder3.getTradingId();
			BigDecimal totalPrice = placeOrder3.getPayableAmount();

			Long thirdTradingId = TradingCallService.payOrder(userId,
					BigDecimal.ZERO, tradingId, "13");

			PayGateWayCallService.notifyCall("13", thirdTradingId.toString(),
					totalPrice.subtract(BigDecimal.ZERO).toString(), userId);
			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(5000);

			// 拼邮国际段发货
			TradingCallService.delivery(sellerId, orderId,
					LogisticsTypeEnum.OVERSEAS_DELIVERY, 1);
			TradingSyncService.getSyncResult(orderId);
			// 拼邮国内段发货
			TradingCallService.delivery(sellerId, orderId,
					LogisticsTypeEnum.OVERSEAS_DELIVERY, 3);

			TradingCallService.confirmReceive(userId, orderId);
			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId001, userId, sellerId001,
					latestHunter);
			TradingSyncService.verify(orderId002, userId, sellerId002,
					latestHunter);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_TradingSync_055() {
		Logger.start(true, "分销系统触发成为推手时，将该用户之前未付款订单，更新至最新关联关系");

		/**
		 * 
		 1、用户P之前有未付款的普通商品 2、用户P没有已支付的订单
		 */

		try {
			// 创建订单
			Logger.comment("前置数据准备");

			int userId = new OrderCallService().createNewUser();

			long hunterId001 = HunterCallService.buildHunterRelation(2, 1, 0)
					.get(0);
			long hunterId002 = HunterCallService.buildHunterRelation(3, 1, 0)
					.get(0);

			TradingServiceResp placeOrder1 = TradingPlaceHunterOrderCallService
					.placeHunterOrder(hunterId001, userId, 2);
			long sellerId001 = placeOrder1.getOrderList().get(0).getSellerId();
			long orderId001 = placeOrder1.getOrderList().get(0).getOrderId();

			TradingServiceResp placeOrder2 = TradingPlaceHunterOrderCallService
					.placeHunterOrder(hunterId002, userId, 2);
			long sellerId002 = placeOrder2.getOrderList().get(0).getSellerId();
			long orderId002 = placeOrder2.getOrderList().get(0).getOrderId();

			long latestHunter = HunterCallService.buildHunterRelation(3, 1, 0)
					.get(0);
			TradingServiceResp placeOrder3 = TradingPlaceHunterOrderCallService
					.placeHunterOrder(latestHunter, userId, 1);

			long sellerId = placeOrder3.getOrderList().get(0).getSellerId();
			long orderId = placeOrder3.getOrderList().get(0).getOrderId();
			long tradingId = placeOrder3.getTradingId();
			BigDecimal totalPrice = placeOrder3.getPayableAmount();

			Long thirdTradingId = TradingCallService.payOrder(userId,
					BigDecimal.ZERO, tradingId, "13");

			PayGateWayCallService.notifyCall("13", thirdTradingId.toString(),
					totalPrice.subtract(BigDecimal.ZERO).toString(), userId);
			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(5000);

			// 拼邮国际段发货
			TradingCallService.delivery(sellerId, orderId,
					LogisticsTypeEnum.OVERSEAS_DELIVERY, 1);
			TradingSyncService.getSyncResult(orderId);
			// 拼邮国内段发货
			TradingCallService.delivery(sellerId, orderId,
					LogisticsTypeEnum.OVERSEAS_DELIVERY, 3);

			TradingCallService.confirmReceive(userId, orderId);
			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId001, userId, sellerId001, userId);
			TradingSyncService.verify(orderId002, userId, sellerId002, userId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_TradingSync_056() {
		Logger.start(true, "交易定金下单,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrder = TradingPlaceEngageOrderCallService
					.placeEngageOrder(false);

			long userId = placeOrder.getUserId();

			long sellerId = placeOrder.getOrderList().get(0).getSellerId();

			long orderId = placeOrder.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_057() {
		Logger.start(true, "定金订单支付定金,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrder = TradingPlaceEngageOrderCallService
					.placeEngageOrder(false);

			long userId = placeOrder.getUserId();
			long sellerId = placeOrder.getOrderList().get(0).getSellerId();
			long orderId = placeOrder.getOrderList().get(0).getOrderId();
			long tradingId = placeOrder.getTradingId();
			BigDecimal earnestAmount = placeOrder.getOrderList().get(0)
					.getOrderPo().getEarnestAmount();

			TradingCallService.payEngageOrder(userId, earnestAmount, tradingId);

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_058() {
		Logger.start(true, "定金订单二次确认下单,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrder = TradingPlaceEngageOrderCallService
					.placeEngageOrder(false);

			long userId = placeOrder.getUserId();
			long sellerId = placeOrder.getOrderList().get(0).getSellerId();
			long orderId = placeOrder.getOrderList().get(0).getOrderId();
			long tradingId = placeOrder.getTradingId();
			BigDecimal earnestAmount = placeOrder.getOrderList().get(0)
					.getOrderPo().getEarnestAmount();

			TradingCallService.payEngageOrder(userId, earnestAmount, tradingId);

			// 二次确认下单
			List<Long> bookingConfirmOrderIds = new ArrayList<Long>();
			bookingConfirmOrderIds.add(orderId);

			TradingPlaceEngageOrderCallService
					.placeOrderWithBookingConfirmOrderIds(bookingConfirmOrderIds);
			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_059() {
		Logger.start(true, "定金订单支付全款并接单,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrder = TradingPlaceEngageOrderCallService
					.placeEngageOrder(false);

			long userId = placeOrder.getUserId();
			long sellerId = placeOrder.getOrderList().get(0).getSellerId();
			long orderId = placeOrder.getOrderList().get(0).getOrderId();
			long tradingId = placeOrder.getTradingId();
			BigDecimal earnestAmount = placeOrder.getOrderList().get(0)
					.getOrderPo().getEarnestAmount();

			TradingCallService.payEngageOrder(userId, earnestAmount, tradingId);
			TradingSyncService.getSyncResult(orderId);

			TradingCallService.payFullPaidOrder(userId, orderId);
			TradingSyncService.getSyncResult(orderId);
			TradingCallService.sellerAcceptOrder(sellerId, orderId);
			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_060() {
		Logger.start(true, "定金订单二次确认下单，使用商家+平台优惠，使用预付卡，使用商家促销信息,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrderResp = TradingPlaceEngageOrderCallService
					.placeEngageOrder2Order(false);
			TradingServiceResp secondConfirmOrderResp = TradingPlaceEngageOrderCallService
					.placeFullPaidOrderWithAllPromotion(placeOrderResp);

			long orderId = secondConfirmOrderResp.getOrderList().get(0)
					.getOrderId();
			long sellerId = secondConfirmOrderResp.getOrderList().get(0)
					.getSellerId();
			long userId = secondConfirmOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_061() {
		Logger.start(true, "定金订单，支付全款后，未发货前全部退款");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrder = TradingPlaceEngageOrderCallService
					.placeEngageOrder(false);

			long userId = placeOrder.getUserId();
			long sellerId = placeOrder.getOrderList().get(0).getSellerId();
			long orderId = placeOrder.getOrderList().get(0).getOrderId();
			long tradingId = placeOrder.getTradingId();
			BigDecimal earnestAmount = placeOrder.getOrderList().get(0)
					.getOrderPo().getEarnestAmount();

			TradingCallService.payEngageOrder(userId, earnestAmount, tradingId);
			TradingSyncService.getSyncResult(orderId);

			TradingCallService.payFullPaidOrder(userId, orderId);
			TradingSyncService.getSyncResult(orderId);

			Logger.comment("前置数据准备结束");

			TradingCallService.cancelOrder(orderId,
					CancelOrderTypeEnum.SYSTEM_CANCEL_ORDER, userId);

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_062() {
		Logger.start(true, "定金订单，二次确认待支付，超时后，系统自动取消，订单回退到定金待二次确认状态");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp engagePlaceOrderResp = TradingPlaceEngageOrderCallService
					.placeEngageOrder(false);

			Long userId = engagePlaceOrderResp.getUserId();
			long tradingId = engagePlaceOrderResp.getTradingId();
			long engageOrderId = engagePlaceOrderResp.getOrderList().get(0)
					.getOrderId();
			long sellerId = engagePlaceOrderResp.getOrderList().get(0)
					.getSellerId();

			// 支付定金
			TradingCallService.payOrder(userId,
					engagePlaceOrderResp.getPayableAmount(), tradingId, 2);
			TradingSyncService.getSyncResult(engageOrderId);

			// 二次确认下单
			TradingPlaceEngageOrderCallService.placeFullPaidOrder(userId,
					engageOrderId);
			TradingSyncService.getSyncResult(engageOrderId);

			// 修改二次确认时间
			OrderShardingWapper orderShardingWapper = new OrderShardingWapper();

			OrderPo record = orderShardingWapper
					.selectOrderbyOrderId(engageOrderId);

			Calendar calendar = Calendar.getInstance();
			calendar.setTime(new Date());
			calendar.add(Calendar.DAY_OF_MONTH, -10);

			record.setSecondConfirmTime(calendar.getTime());

			// 修改二次确认时间
			orderShardingWapper.orderMapper.updateByPrimaryKey(record);

			String orderJson = "{\"cancelReason\":\"自动化测试取消订单\",\"cancelType\":\"10\",\"orderId\":"
					+ engageOrderId + ",\"userId\":" + userId + "}";
			// 发送请求
			YmatouEasyCall autoCancelOrderCall = new YmatouEasyCall("", "POST",
					"JSON");
			autoCancelOrderCall
					.setUrl("http://optrade.iapi.ymatou.com/api/Buyer/bookingOrderUnPaidFullAmountAutoCancel");
			autoCancelOrderCall.setData(orderJson);
			autoCancelOrderCall.callService();

			TradingSyncService.getSyncResult(engageOrderId);

			TradingSyncService.verify(engageOrderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_079() {
		Logger.start(true, "交易下单带有国际拼邮类型,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrder = TradingPlaceOrderCallService
					.placeOrderWithPackageDeliveryType(1);

			long userId = placeOrder.getUserId();

			long sellerId = placeOrder.getOrderList().get(0).getSellerId();

			long orderId = placeOrder.getOrderList().get(0).getOrderId();

			// 支付订单
			TradingCallService.payOrder(userId, placeOrder.getPayableAmount(),
					placeOrder.getTradingId());
			// 接单
			TradingCallService.sellerAcceptOrder(sellerId, orderId);
			TradingSyncService.getSyncResult(orderId);

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_090() {
		Logger.start(true, "创建一个安利会的订单,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 创建一个拼邮的订单
			TradingServiceResp placeOrderResp = TradingPlaceAnliOrderCallService
					.placeAnlihuiOrder(BigDecimal.TEN, false);

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_091() {
		Logger.start(true, "创建一个安利会的订单并支付,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			// 创建一个拼邮的订单
			TradingServiceResp placeOrderResp = TradingPlaceAnliOrderCallService
					.placeAnlihuiOrder(BigDecimal.ZERO, false, 20226434L, 3);

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			long userId = placeOrderResp.getUserId();

			TradingSyncService.getSyncResult(orderId);

			// 支付订单
			TradingCallService.payOrder(userId,
					placeOrderResp.getPayableAmount(),
					placeOrderResp.getTradingId());

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_092() {
		Logger.start(true, "使用了返点金额，退款成功,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrderResp = TradingPlaceAnliOrderCallService
					.placeAnlihuiOrder(BigDecimal.TEN, false);

			Order order = placeOrderResp.getOrderList().get(0);

			Long userId = placeOrderResp.getUserId();
			Long orderId = order.getOrderId();

			long sellerId = order.getSellerId();

			// 支付
			TradingCallService.payOrder(placeOrderResp.getUserId(),
					placeOrderResp.getPayableAmount(),
					placeOrderResp.getTradingId());
			// 接单
			TradingCallService.sellerAcceptOrder(order.getSellerId(), orderId);

			// 退款
			RefundService.approveRefund(order);
			TradingSyncService.getSyncResult(orderId);

			Thread.sleep(5000);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_094() {
		Logger.start(true, "创建一个安利会的订单,未产生返点，并支付,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrderResp = TradingPlaceAnliOrderCallService
					.placeAnlihuiOrder(BigDecimal.TEN, false);

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			long userId = placeOrderResp.getUserId();

			TradingSyncService.getSyncResult(orderId);

			// 支付订单
			TradingCallService.payOrder(userId,
					placeOrderResp.getPayableAmount(),
					placeOrderResp.getTradingId());

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_TradingSync_095() {
		Logger.start(true, "海淘达人自购商品，验证同步");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			OrderCallService orderCallService = new OrderCallService();
			int userId = orderCallService.createNewUser();

			// 构建memberRelation
			List<Long> daren_member_List = AnlihuiCallService
					.buildAnlihuiMemberRelation(3, 4, 0);

			AnlihuiCallService.insertAnlihuiMember(userId, 3,
					daren_member_List.get(2));

			int memberOrderType = 0;

			TradingServiceResp placeOrder = TradingPlaceAnliOrderCallService
					.placeAnlihuiOrder((long) userId, BigDecimal.ZERO, false,
							(long) userId, memberOrderType);
			long sellerId = placeOrder.getOrderList().get(0).getSellerId();
			long orderId = placeOrder.getOrderList().get(0).getOrderId();
			long tradingId = placeOrder.getTradingId();
			BigDecimal totalPrice = placeOrder.getPayableAmount();

			Long thirdTradingId = TradingCallService.payOrder(userId,
					BigDecimal.ZERO, tradingId, "13");

			PayGateWayCallService.notifyCall("13", thirdTradingId.toString(),
					totalPrice.subtract(BigDecimal.ZERO).toString(), userId);
			TradingSyncService.getSyncResult(orderId);

			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_TradingSync_096() {
		Logger.start(true, "一个安利会主单，包含一个普通商品订单和一个会员订单，验证同步");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrderResp = TradingPlaceAnliOrderCallService
					.placeAnlihuiMemberAndAnlihuiNormalOrder(20238699,
							24635724, 2);

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			long userId = placeOrderResp.getUserId();

			Thread.sleep(10000);

			Logger.comment("前置数据准备结束");

			OrderPo orderPo = new OrderShardingWapper()
					.selectOrderbyOrderIdAndOrderType(orderId, 0);

			if (orderPo == null) {

				orderId = placeOrderResp.getOrderList().get(1).getOrderId();
			}

			// 支付订单
			TradingCallService.payOrder(userId,
					placeOrderResp.getPayableAmount(),
					placeOrderResp.getTradingId());

			Thread.sleep(5000);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_099() {
		Logger.start(true, "创建一订单,产生返点，并支付,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrderResp = TradingPlaceOrderCallService
					.placeOrderWithRebatePaidAmount(BigDecimal.TEN);

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			long userId = placeOrderResp.getUserId();

			TradingSyncService.getSyncResult(orderId);

			// 支付订单
			TradingCallService.payOrder(userId,
					placeOrderResp.getPayableAmount(),
					placeOrderResp.getTradingId());

			Logger.comment("前置数据准备结束");

			Thread.sleep(5000);

			// // 接单
			// TradingCallService.sellerAcceptOrder(sellerId, orderId);
			// TradingSyncService.getSyncResult(orderId);
			//
			// // 拼邮国际段发货
			// TradingCallService.delivery(sellerId, orderId,
			// LogisticsTypeEnum.PackageDelivery, 1);
			// TradingSyncService.getSyncResult(orderId);
			//
			// // 拼邮国内段发货
			// TradingCallService.delivery(sellerId, orderId,
			// LogisticsTypeEnum.PackageDelivery, 3);
			// TradingSyncService.getSyncResult(orderId);
			//
			// // 确认收货
			// TradingCallService.confirmReceive(userId, orderId);
			// TradingSyncService.getSyncResult(orderId);
			//
			// // 退款
			// RefundService.applyRefund(placeOrderResp.getOrderList().get(0));
			//
			// RefundService.approveRefund(placeOrderResp.getOrderList().get(0));

			Thread.sleep(4000);

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_0106() {
		Logger.start(true, "订单支付,满减包邮，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrder = TradingPlaceOrderCallService
					.placeOrderWithFullReductionFreeFreight(true);

			long userId = placeOrder.getUserId();
			long sellerId = placeOrder.getOrderList().get(0).getSellerId();

			long tradingId = placeOrder.getTradingId();

			long orderId = placeOrder.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");
			// 支付订单
			TradingCallService.payOrder(userId, placeOrder.getPayableAmount(),
					tradingId);

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_121() {
		Logger.start(true, "交易下单,带有ubuy信息，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			UbuyUserVo ubuyUserVo = new UbuyUserVo();

			ubuyUserVo.setPassport(TestDataManager.randomStr(10) + "passport");
			ubuyUserVo.setPassportIssuePlace(TestDataManager.randomStr(10)
					+ "passportIssuePlace");
			ubuyUserVo.setUserName(TestDataManager.getChineseName()
					+ "userName");

			TradingServiceResp placeOrder = TradingPlaceOrderCallService
					.placeOrderWithUbuy(ubuyUserVo);

			long userId = placeOrder.getUserId();
			long sellerId = placeOrder.getOrderList().get(0).getSellerId();
			long orderId = placeOrder.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_122() {
		Logger.start(true, "交易下单,带有GraphicProduct， 验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrder = TradingPlaceOrderCallService
					.placeOrderWithGraphicProduct(true);

			long userId = placeOrder.getUserId();

			long sellerId = placeOrder.getOrderList().get(0).getSellerId();

			long orderId = placeOrder.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_123() {
		Logger.start(true, "交易下单,带有ThirdPartyPromotion， 验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrder = TradingPlaceOrderCallService
					.placeOrderWithThirdPartyPromotion();

			long userId = placeOrder.getUserId();

			long sellerId = placeOrder.getOrderList().get(0).getSellerId();

			long orderId = placeOrder.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_124() {
		Logger.start(true, "交易下单,带有奢品， 验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrder = TradingPlaceOrderCallService
					.placeOrderWithLuxury(true);

			long userId = placeOrder.getUserId();

			long sellerId = placeOrder.getOrderList().get(0).getSellerId();

			long orderId = placeOrder.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_125() {
		Logger.start(true, "拼邮订单的运单国际、国内段均签收，订单签收状态为true， 验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrderResp = TradingPlaceOrderCallService
					.placeOrderWithLogisticsType(LogisticsTypeEnum.OVERSEAS_DELIVERY);

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			long userId = placeOrderResp.getUserId();
			long tradingId = placeOrderResp.getTradingId();

			BigDecimal useAccountAmount = placeOrderResp.getPayableAmount();

			TradingCallService.payOrder(userId, useAccountAmount, tradingId);
			TradingSyncService.getSyncResult(orderId);

			TradingCallService.sellerAcceptOrder(sellerId, orderId);
			TradingSyncService.getSyncResult(orderId);

			String billCode = TradingCallService.delivery(sellerId, orderId,
					LogisticsTypeEnum.OVERSEAS_DELIVERY, 1);
			TradingSyncService.getSyncResult(orderId);

			// 国际段签收
			TradingCallService.saveLogisticsInfo(billCode);

			billCode = TradingCallService.delivery(sellerId, orderId,
					LogisticsTypeEnum.OVERSEAS_DELIVERY, 3);
			TradingSyncService.getSyncResult(orderId, "LOGISTICS_CODE");

			// 国内段签收
			TradingCallService.saveLogisticsInfo(billCode);
			TradingSyncService.getSyncResult(orderId, "LOGISTICS_CODE");

			Logger.comment("前置数据准备结束");

			TradingCallService.syncSignedOrderBizParam(orderId, billCode);
			TradingSyncService.getSyncResult(orderId, "LOGISTIC_SIGN");

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_126() {
		Logger.start(true, "交易下单,买家承担鉴定费和鉴定物流费， 验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrder = TradingPlaceAuthenticateCallService
					.placeOrderWithAuthenticate(
							AuthenticateFreightTypeEnum.BUYER, BigDecimal.ONE,
							AuthenticateFeeTypeEnum.BUYER, BigDecimal.TEN);

			long userId = placeOrder.getUserId();

			long sellerId = placeOrder.getOrderList().get(0).getSellerId();

			long orderId = placeOrder.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_127() {
		Logger.start(true, "交易下单,买手承担鉴定费和鉴定物流费， 验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrder = TradingPlaceAuthenticateCallService
					.placeOrderWithAuthenticate(
							AuthenticateFreightTypeEnum.SELLER, BigDecimal.ONE,
							AuthenticateFeeTypeEnum.SELLER, BigDecimal.TEN);

			long userId = placeOrder.getUserId();

			long sellerId = placeOrder.getOrderList().get(0).getSellerId();

			long orderId = placeOrder.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_128() {
		Logger.start(true, "交易下单,买手承担鉴定费和鉴定物流费， 余额支付订单，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrder = TradingPlaceAuthenticateCallService
					.placeOrderWithAuthenticate(
							AuthenticateFreightTypeEnum.SELLER, BigDecimal.ONE,
							AuthenticateFeeTypeEnum.SELLER, BigDecimal.TEN);

			long userId = placeOrder.getUserId();

			long sellerId = placeOrder.getOrderList().get(0).getSellerId();

			long orderId = placeOrder.getOrderList().get(0).getOrderId();

			TradingCallService.payOrder(userId, placeOrder.getPayableAmount(),
					placeOrder.getMainOrderId());

			TradingCallService.sellerAcceptOrder(sellerId, orderId);
			
			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_129() {
		Logger.start(true, "交易下单,买家承担鉴定费和鉴定物流费， 第三方支付订单，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrder = TradingPlaceAuthenticateCallService
					.placeOrderWithAuthenticate(
							AuthenticateFreightTypeEnum.BUYER, BigDecimal.ONE,
							AuthenticateFeeTypeEnum.BUYER, BigDecimal.TEN);

			long userId = placeOrder.getUserId();

			long sellerId = placeOrder.getOrderList().get(0).getSellerId();

			long orderId = placeOrder.getOrderList().get(0).getOrderId();

			String payType = "15";

			Long thirdTradingId = TradingCallService.payOrder(userId,
					BigDecimal.ZERO, placeOrder.getMainOrderId(), payType);

			// 支付网关支付回调
			PayGateWayCallService.notifyCall(payType,
					thirdTradingId.toString(), placeOrder.getPayableAmount()
							.subtract(BigDecimal.ZERO).toString(), userId);

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingCallService.sellerAcceptOrder(sellerId, orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_130() {
		Logger.start(true, "交易下单,买手承担鉴定费和鉴定物流费， 余额支付订单，到达鉴定中心，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrder = TradingPlaceAuthenticateCallService
					.placeOrderWithAuthenticate(
							AuthenticateFreightTypeEnum.SELLER, BigDecimal.ONE,
							AuthenticateFeeTypeEnum.SELLER, BigDecimal.TEN);

			long userId = placeOrder.getUserId();

			long sellerId = placeOrder.getOrderList().get(0).getSellerId();

			long orderId = placeOrder.getOrderList().get(0).getOrderId();

			TradingCallService.payOrder(userId, placeOrder.getPayableAmount(),
					placeOrder.getMainOrderId());

			TradingCallService.authenticateCenterNotify(orderId, placeOrder
					.getOrderList().get(0).getOrderDetailPoList().get(0)
					.getCatalogId());

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_131() {
		Logger.start(true, "交易下单,买家承担鉴定费和鉴定物流费， 鉴定中心发起退款，退货退款成功，验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			TradingServiceResp placeOrderResp = TradingPlaceAuthenticateCallService
					.placeOrderWithAuthenticate(
							AuthenticateFreightTypeEnum.BUYER, BigDecimal.ONE,
							AuthenticateFeeTypeEnum.BUYER, BigDecimal.TEN);

			Long userId = placeOrderResp.getUserId();
			Order order = placeOrderResp.getOrderList().get(0);

			long orderId = order.getOrderId();
			Long sellerId = order.getSellerId();

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			TradingCallService.payOrder(placeOrderResp.getUserId(), totalPrice,
					placeOrderResp.getTradingId());

			// 接单
			TradingCallService.sellerAcceptOrder(order.getSellerId(), orderId);
			TradingSyncService.getSyncResult(orderId);

			TradingCallService.delivery(sellerId, orderId,
					LogisticsTypeEnum.OVERSEAS_DELIVERY, "Y013", 3, true);
			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(3000);

			// 确认收货
			TradingCallService.confirmReceive(userId, orderId);
			TradingSyncService.getSyncResult(orderId);

			Logger.comment("前置数据准备结束");

			RefundService.approveRefundViaAuthenticateCenter(order);

			Thread.sleep(3000);

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_132() {
		Logger.start(true, "补录物流单号,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrderResp = TradingPlaceOrderCallService
					.placeOrderWithLogisticsType(LogisticsTypeEnum.OVERSEAS_DELIVERY);

			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			long userId = placeOrderResp.getUserId();

			long tradingId = placeOrderResp.getTradingId();

			BigDecimal useAccountAmount = placeOrderResp.getPayableAmount();

			TradingCallService.payOrder(userId, useAccountAmount, tradingId);

			TradingCallService.sellerAcceptOrder(sellerId, orderId);

			TradingCallService.delivery(sellerId, orderId,
					LogisticsTypeEnum.OVERSEAS_DELIVERY, 1);

			Thread.sleep(3000);
			Logger.comment("前置数据准备结束");

			// 商家补录运单
			TradingCallService.modifyOrSupplementBillNo(orderId, sellerId,
					"Y013", 3);

			TradingSyncService.syncOrderCmd(userId, orderId,
					TradingSyncCmdEnum.LOGISTICS_CODE);

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_133() {
		Logger.start(true, "交易下单,官方物流带签收时效， 验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrder = TradingPlaceAuthenticateCallService
					.placeOrderWithAuthenticateAndOfficialLogistics(
							AuthenticateFreightTypeEnum.BUYER, BigDecimal.ONE,
							AuthenticateFeeTypeEnum.BUYER, BigDecimal.TEN);

			long userId = placeOrder.getUserId();

			long sellerId = placeOrder.getOrderList().get(0).getSellerId();

			long orderId = placeOrder.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_TradingSync_134() {
		Logger.start(true, "交易下单,带有奢品,鉴定规则id， 验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			TradingServiceResp placeOrder = TradingPlaceOrderCallService
					.placeOrderWithAuthenticateRuleId(1L);
			

			long userId = placeOrder.getUserId();

			long sellerId = placeOrder.getOrderList().get(0).getSellerId();

			long orderId = placeOrder.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");

			TradingSyncService.getSyncResult(orderId);

			TradingSyncService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	// @Test
	// @Category(P1.class)
	// @TestCase
	// public void Tc_TradingSync_062() {
	// Logger.start(true, "测试");
	// try {
	// // 创建订单
	// Logger.comment("前置数据准备");
	//
	// TradingServiceResp placeOrder = TradingCallService
	// .placeEngageOrder(false);
	//
	// long userId = placeOrder.getUserId();
	// long tradingId = placeOrder.getTradingId();
	// long sellerId = placeOrder.getOrderList().get(0).getSellerId();
	// BigDecimal earnestAmount =
	// placeOrder.getOrderList().get(0).getOrderPo().getEarnestAmount();
	// long orderId = placeOrder.getOrderList().get(0).getOrderId();
	//
	// TradingCallService.payEngageOrder(userId, earnestAmount, tradingId);
	// TradingServiceResp fullPlaceOrder =
	// TradingCallService.placeFullPaidOrder(userId, orderId);
	//
	//
	// List<Order> engageOrder = fullPlaceOrder.getOrderList().stream()
	// .filter(o -> o.getOrderId() == orderId).collect(Collectors.toList());
	//
	// Logger.comment("前置数据准备结束");
	//
	// } catch (Exception e) {
	// Logger.fail(e);
	// }
	// }

	public static void main(String[] args) throws ClientProtocolException,
			IOException {
		// 手动同步一次商品
		// YmatouEasyCall getProdCall = new YmatouEasyCall("", "GET", null);
		//
		// getProdCall
		// .setUrl("http://productsync.iapi.ymatou.com/api/cache/mongocrud?ActionType=CreateProduct&ActivityId=0&TransactionId=322487428&ProductId="
		// + "p1651066");
		// getProdCall.setData("");
		// getProdCall.callService();

	}
}